#include <stdio.h>
#include <stdlib.h>
int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
int main(void) {
	int n, a, b;
	for (scanf("%d", &n); n--;) {
		scanf("%d%d", &a, &b);
		printf("%d %d\n", gcd(a, b), lcm(a, b));
	}
	return EXIT_SUCCESS;
}
